package com.netafull;

import jp.co.nobot.libAdMaker.libAdMaker;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;

public class ShowAdActivity extends Activity {

	protected boolean bAdShow = true;

	public static int ad_id = 1;
	
	libAdMaker AdMaker;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
	}
	public void onResume() {
		super.onResume();
		//System.out.println("super resume");
		//show();
	}

	public void show() {
		ad_id = 3;
		System.out.println("开始加载广告");
		if (ad_id == 1) {
			LinearLayout linearlayoutAd = (LinearLayout) findViewById(R.id.admob);
			linearlayoutAd.setVisibility(View.VISIBLE);
			AdView adView = new AdView(this, AdSize.BANNER, "a14e16d62436813");
			linearlayoutAd.addView(adView);
			adView.loadAd(new AdRequest());
		} else if (ad_id == 2) {
			LinearLayout linearlayoutAd = (LinearLayout) findViewById(R.id.admaker);
			linearlayoutAd.setVisibility(View.VISIBLE);
			//libAdMaker AdMaker = (libAdMaker) findViewById(R.id.admakerview);
			AdMaker = (libAdMaker) findViewById(R.id.admakerview);
			AdMaker.setActivity(this);
			AdMaker.siteId = "609";
			AdMaker.zoneId = "4708";
			AdMaker.setUrl("http://images.ad-maker.info/apps/twzr9t2eaher.html");
			AdMaker.start();
		} else if (ad_id == 3) {
			LinearLayout linearlayoutAd = (LinearLayout) findViewById(R.id.adlantis);
			linearlayoutAd.setVisibility(View.VISIBLE);
		} else if (ad_id == 4) {
			LinearLayout linearlayoutAd = (LinearLayout) findViewById(R.id.adsense);
			linearlayoutAd.setVisibility(View.VISIBLE);
			WebView webView = (WebView) findViewById(R.id.adsenseview);
			WebSettings webSettings = webView.getSettings();
			webSettings.setJavaScriptEnabled(true);
			webView.loadUrl("file:///android_asset/adsense.html");
		}
	}
	@Override
	protected void onDestroy() {
		if (AdMaker!=null) {
			// TODO Auto-generated method stub
			AdMaker.end();
		}
		super.onDestroy();
	}
}
